package com.game.sprite;

import java.util.HashMap;
import java.util.Map;

import android.graphics.Bitmap;
import android.graphics.Canvas;

public class SpriteFont {
	
	
	
	//para desenhar
	private Bitmap bitmap;
	
	
	//mapa de caracteres com as letras
	private Map<Character, Bitmap> glypho = new HashMap<Character, Bitmap>(62);
	
	
	//altura largura e posição do caracter na imagem
	private int width;
	private int height;
	private int x;
	private int y;
	
	
	//TODO - ir até o final
	private char[] charactersL = new char[] 
			{'a','b','c','d','e','f'};
	
	
	//TODO - ir até o final
	private char[] charactersU = new char[] 
			{'A','B','C','D','E','F'};
	
	public SpriteFont(Bitmap bitmap){
		
		this.bitmap = bitmap;
		this.width = 8;
		this.height = 12;
		this.x = 0;
		this.y = 0;
		
		for(int i=0; i<charactersL.length;i++){
			
			glypho.put(charactersL[i], Bitmap.createBitmap(bitmap, 0 + (i*width), 0, width, height));
		}
		
		for(int i=0; i<charactersU.length;i++){
			glypho.put(charactersU[i], Bitmap.createBitmap(bitmap, 0 + (i*width), 15, width, height));
		}
	}
	
	
	
	public void drawString(Canvas canvas, String text, int x, int y){
		
		for(int i=0;i<text.length();i++)
		{
			char ch = text.charAt(i);
			Bitmap currentBitmap = glypho.get(ch);
			
			if(currentBitmap != null){
				
				canvas.drawBitmap(currentBitmap, x + (i * width), y, null);
			}
		}
	}
	

}
